__author__ = 'ila'

from datetime import datetime
from api.models.models import Base_model
from api.exts import db

class shangjia(Base_model):
    __doc__ = '商户表'
    __tablename__ = 'shangjia'
    __table_args__ = {'extend_existing': True} 
    
    id = db.Column(db.BigInteger, primary_key=True)
    shangjiazhanghao = db.Column(db.String(200), nullable=False, unique=True, info='商户账号')
    mima = db.Column(db.String(200), nullable=False, info='密码')
    shangjiamingcheng = db.Column(db.String(200), nullable=True, info='商户名称')
    lianxidianhua = db.Column(db.String(200), nullable=True, info='联系电话')
    youxiang = db.Column(db.String(200), nullable=True, info='邮箱')
    touxiang = db.Column(db.Text, nullable=True, info='头像')
    status = db.Column(db.Integer, default=0, nullable=True, info='状态(0:待审核,1:正常,2:禁用)')
    reason = db.Column(db.String(200), nullable=True, info='驳回原因')
    addtime = db.Column(db.DateTime, nullable=False, default=datetime.now, server_default=db.FetchedValue(), info='创建时间')
    def save(self):
        db.session.add(self)
        db.session.commit()
        
    def update(self):
        db.session.commit()